import { Injectable } from '@nestjs/common';
import { CreateBannerDto } from './dto/create-banner.dto';
import { UpdateBannerDto } from './dto/update-banner.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, Like } from 'typeorm';
import { Banner } from './entities/banner.entity';

@Injectable()
export class BannerService {

  constructor(
    @InjectRepository(Banner)
    private readonly bannerRepository: Repository<Banner>
  ) { }

  create(createBannerDto: CreateBannerDto) {
    return this.bannerRepository.save(createBannerDto);
  }

  async findAll(query: any) {
    const { skip, take } = query;
    return await this.bannerRepository.findAndCount({
      where: {},
      order: { order_number: 'ASC' },
      skip,
      take
    });
  }

  findOne(id: number) {
    return `This action returns a #${id} banner`;
  }

  update(id: number, updateBannerDto: UpdateBannerDto) {
    return `This action updates a #${id} banner`;
  }

  remove(id: number) {
    return `This action removes a #${id} banner`;
  }
}
